<?php

class HTML_Object extends HTML implements HTMLElements {
	private $attributeData;
	private $attriubteType;
	
	const HTML_OBJECT = 'object';
	const ATTRIBUTE_DATA = 'data';
	const ATTRIBUTE_TYPE = 'type';
	
	const TYPE_IMAGE_SVG = 'image/svg+xml';
	
/**
	 * 
	 * This function creates a complete Link-Element.
	 * The attributes have to be passed within an array. Possible attributes are:
	 * 	- $class
	 * 	- $id
	 * 	- $title
	 *  - $alt
	 *  - $src
	 * @param unknown_type $parent
	 * @param String[][] $properties
	 */
	public function __construct($parent, $properties)  {
		PropertySetter::setProperties($this, $properties);
		$parent->addChildElement($this);
	}
	
	public function setAttributeType ($type)  {
		$this->attributeType = $type;
	}
	
	public function setAttributeData ($data)  {
		$this->attributeData = $data;
	}
	
	public function getAttributeType ()  {
		return $this->attributeType;
	}
	
	public function getAttributeData ()  {
		return $this->attributeData;
	}
	
	public function getObjectAttributes ()  {
		
		$output = '';
		
		if (!empty($this->attributeData))  {
			$output .= ' '. self::ATTRIBUTE_DATA. '="'. $this->getAttributeData(). '"';
		}
		if (!empty($this->attributeType))  {
			$output .= ' '. self::ATTRIBUTE_TYPE. '="'. $this->getAttributeType(). '"';
		}
		
		if ($output == '')  {
			$output = ' ';
		}
		
		return $output;
		
	}
	
	public static function getAttributes ()  {
		$attributes = array();
		$parentAttributes = parent::getAttributes();
		$attributes[] = self::ATTRIBUTE_TYPE;
		$attributes[] = self::ATTRIBUTE_DATA;
		
		return array_merge($parentAttributes, $attributes);
	}
	
	public function toString ()  {
		$output = '<'. self::HTML_OBJECT.
					$this->getHTMLAttributes().
					$this->getObjectAttributes(). '>';
		
		$output .= '</'. self::HTML_OBJECT. '>';
		
		return $output;
	}
	
}
?>